#include <glog/logging.h>
#include "basic/UdpServer.h"

UdpServer::UdpServer(uint16_t server_port, uint16_t clinet_port) {
    _udpServer = std::make_shared<UDPServer<>>();
    _clinet_port = clinet_port;
    _server_port = server_port;
}

void UdpServer::UDPServerStart() {
    _udpServer->Bind(_server_port, [](int errorCode, std::string errorMessage) {
        LOG(ERROR) << "[COMMU]" << errorCode << " : " << errorMessage;
    });
}

void UdpServer::UDPServerSend(std::string ipv4, std::string msg) {
    _udpServer->SendTo(msg, ipv4, _clinet_port);
}

void UdpServer::UDPServerSend(std::string ipv4, uint16_t port, std::string msg) {
    _udpServer->SendTo(msg, ipv4, port);
}